@extends('layouts.default') @section('main')
    <link rel="stylesheet" href="/css/uniform.css" />
    <link rel="stylesheet" href="/css/select2.css" />
    <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,800' rel='stylesheet' type='text/css'>
    <div id="content">
        <div id="content-header">
            <div id="breadcrumb">
                <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i class="icon-home"></i> 首页</a>
                <a href="#" class="current">活动-游戏列表</a>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span12">
                    @if(in_array('add',$actions)) <a href="{{url('game/create')}}"><button class="btn">新增</button></a> @endif

                    <form action="{{url('game/search')}}" method="post">
                        <table>
                            <tr>
                                <th>
                                    <label >活动主题 :</label>
                                </th>
                                <th>
                                    <div class="controls">
                                        <input type="text" class="span11" name="subject"  placeholder="活动主题" />
                                    </div>
                                </th>
                                <th>
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <div class="controls">
                                        <button type="submit" class="btn btn-info">查询</button>
                                    </div>
                                </th>
                            </tr>
                        </table>
                    </form>

                    <div class="widget-box">
                        <div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>
                            <h5>活动-游戏管理</h5>
                        </div>

                        <div class="widget-content nopadding">
                            <table class="table table-bordered table-striped">
                                <thead>
                                <tr>
                                    <th>关联的活动(主题)</th>
                                    <th>游戏链接（通往前台）</th>
                                    <th>查看详情</th>
                                    <th>游戏管理</th>
                                    <th>活动签到二维码</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                @foreach($lists as $key => $list)
                                    <tr class="gradeX">
                                        <td title="{{$list['activity_name']}}">@if($list['activity_name']){{ cut_str($list['activity_name'],12)}}@endif</td>
                                        <td> @foreach($list['games'] as $k=>$v) <a href="{{$wjtrUrl.'cj?activity_id='.$list['id'].'&code='.$v->type->code}}">{{$v->title}}</a> <br /> @endforeach</td>
                                        {{--<td><a href="{{$wjtrUrl.'game/index?id='.$list['id']}}">{{$list->title}}</a></td>--}}
                                        <td><a href="{{url('game/info?id='.$list['id'])}}">点击查看</a></td>
                                        <td><a href="{{url('gamelist/index?id='.$list['id'])}}">点击管理</a></td>
                                        <td><a href="{{url('activity/sign-code?id='.$list['id'])}}">点击查看</a></td>
                                        <td class="center">
                                            {{--@if(in_array('edit',$actions)) <a data-original-title="编辑" class="tip" href="{{url('game/edit?id='.$list['id'])}}"><i class="icon-pencil"></i></a> @endif--}}
                                            @if(in_array('export',$actions)) <a data-original-title="导出获奖者" class="tip" href="{{url('game/export?id='.$list['id'])}}"><i class="icon-external-link"></i></a> @endif
                                            @if(in_array('delete',$actions)) <a data-original-title="删除" data-toggle="modal" class="tip game_delete" activity_id="{{$list['id']}}" href="#myAlert"><i class="icon-remove"></i></a> @endif
                                        </td>
                                    </tr>
                                @endforeach
                                </tbody>
                            </table>
                        </div>
                    </div>
                        <?php echo $lists->render();?>
                </div>
            </div>
        </div>
    </div>
    <div>
        <div id="myAlert" class="modal hide">
            <div class="modal-header">
                <button data-dismiss="modal" class="close" type="button">×</button>
                <h3>提示</h3>
            </div>
            <div class="modal-body">
                <p>确认删除这个活动下面的所有游戏吗？</p>
            </div>
            <div class="modal-footer">
                <a data-dismiss="modal" class="btn btn-primary" href="javascript:void(0);">确定</a>
                <a data-dismiss="modal" class="btn" href="javascript:void(0);">取消</a>
            </div>
        </div>
        <form action="{{url('game/delete')}}" method="post"
              id="gameForm">
            <input type="hidden" name="aid" value="0">
        </form>
    </div>
    <script src="/js/matrix.tables.js"></script>
    <script src="/js/common.js"></script>

    <script>
        $(".game_delete").click(function(){
            var activity_id = $(this).attr("activity_id");
            $("input[name='aid']").val(activity_id);
        });
        $(".btn-primary").click(function(){
            var activity_id = $("input[name='aid']").val();
            if(activity_id == 0){
                alert('参数异常');
                return;
            }
            ajaxRequest($('#gameForm').serializeArray(),$('#gameForm').attr('action'),function(data){
                if(data.status){
                    alert(data.message);
                    window.location.href = data.forwardUrl;
                }else{
                    alert(data.message);
                }
            });
        });
    </script>
@stop
